<!--接口管理页面-->
<style>
    .grid-content {
        margin-bottom: 20px;
        min-height: 36px;
    }
    .el-select  {
        width: 130px;
    }
    .input-with-select .el-input-group__prepend {
        background-color: #fff;
    }
    .el-input-group{
        width: 58% !important
    }
    #freqNum{
        width: 100px !important
    }
</style>
<template>
    <div>
        <el-row>
            <el-col :span="22" class="toolbar marginTop10px " id="serachId">
                <el-form :model="conditionForm" ref="conditionFormRef">
                    <el-form-item style="float:right">
                        <el-button type="primary" size="small" @click="onSearch" >&nbsp;搜索</el-button>
                    </el-form-item>
                    <el-form-item style="float:right;margin-right: 15px;">
                        <el-input v-model="conditionForm.keyword" size="small" auto-complete="off" placeholder="关键字" @keyup.enter.native="onSearch"></el-input>
                    </el-form-item>
                    <el-form-item style="float:right;margin-right: 15px;">
                        <el-select v-model="conditionForm.searchType" size="small" placeholder="请选择">
                            <el-option v-for="item in searchTypeOptions" :key="item.value" :label="item.label"
                                    :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
        <el-row class=" toolbar">
            <el-col :span="23" class="titleLineSymbolTwo">
                <el-table :data="resultDate.data.list" stripe style="width: 100%">
                    <el-table-column type="index" label="序号" min-width="50"></el-table-column>
                    <el-table-column prop="serialNo" label="接口标识" min-width="100"></el-table-column>
                    <el-table-column prop="name" label="接口名称" min-width="160"></el-table-column>
                    <el-table-column prop="path" label="接口地址" min-width="160"></el-table-column>
                    <el-table-column prop="publicPath" label="对外发布地址" min-width="160"></el-table-column>
                    <el-table-column prop="status" label="状态" min-width="100" >
                        <template scope="scope">
                            <span v-html="formatDicTionary(scope.row.status,'status_type')"></span>
                        </template>
                    </el-table-column>

                    <el-table-column label="操作" min-width="100" fixed="right">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="showAccFrom(scope.$index, scope.row)">通用策略</el-button>
                            <el-button type="text" size="small" @click="showCusAccForm(scope.$index, scope.row)">定制策略</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-col  class=" marginTop10px">
                    <el-pagination layout="total, prev, pager, next, jumper" @current-change="handleCurrentPageChange"
                                :current-page="resultDate.data.pageNum"
                                :page-size="resultDate.data.pageSize" :total="resultDate.data.total">
                    </el-pagination>
                </el-col>
            </el-col>

            <!--通用策略界面-->
            <!-- <el-dialog title="通用策略配置" :visible.sync="accFormVisible" width="60%" :before-close="handleClose" :modal-append-to-body="false"> -->
            <Modal v-model="accFormVisible" title="通用策略配置" width='50%' :before-close="handleClose">
                <el-card>
                <el-form :model="accForm" ref="accFormRef" :rules="test">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="频率" :label-width="formLabelWidth">
                                <el-input placeholder="请输入内容" v-model="accForm.simple.frequency" class="input-with-select" id="freqNum" @change="checkNum('frequency','freqNum',accForm.simple)" prop="test">
                                    <el-select v-model="accForm.select" slot="append" placeholder="请选择">
                                        <el-option label="次/小时" value="H"></el-option>
                                        <el-option label="次/每日" value="D"></el-option>
                                        <el-option label="次/每周" value="W"></el-option>
                                        <el-option label="次/每月" value="M"></el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="数据量" :label-width="formLabelWidth" prop="">
                                <el-input v-model="accForm.simple.datasize" placeholder="请输入数据量(byte)" auto-complete="off" id="datasize" @change="checkNum('datasize','datasize',accForm.simple)"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                <!-- <el-form-item label="时间段" :label-width="formLabelWidth" prop="">
                        <el-input placeholder="请输入cron表达式" v-model="accForm.simple.timeSlot" auto-complete="off"></el-input>
                    </el-form-item>-->
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="时间段" :label-width="formLabelWidth" prop="">
                                <el-time-select placeholder="起始时间" v-model="accForm.startTime" :picker-options="{
                                    start: '00:00', step: '00:15', end: '23:59' }">
                                </el-time-select>
                                <el-time-select placeholder="结束时间" v-model="accForm.endTime" :picker-options="{
                                start: '00:00', step: '00:15', end: '23:59', minTime: accForm.startTime }">
                                </el-time-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="ip白名单" :label-width="formLabelWidth" prop="">
                                <el-input placeholder="请输入ip格式为192.168.0.23/32" v-model="accForm.simple.ipWhite" auto-complete="off" id="ipWhite" @change="checkIp('ipWhite','ipWhite',accForm.simple)"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="ip黑名单" :label-width="formLabelWidth" prop="">
                                <el-input placeholder="请输入ip格式为192.168.0.23/32" v-model="accForm.simple.ipBlack" auto-complete="off"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="响应关键字词" :label-width="formLabelWidth" prop="">
                            <el-select v-model="accForm.keySel" multiple placeholder="请选择">
                                <el-option
                                        v-for="item in accForm.keyword"
                                        :key="item.id"
                                        :label="item.keyword"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item label="参数过滤" :label-width="formLabelWidth" prop="">
                        <el-select v-model="paramtmp"  placeholder="请选择">
                            <el-option
                                    v-for="item in accForm.paramInfo"
                                    :key="item.name"
                                    :label="item.name"
                                    :value="item.name">
                            </el-option>
                        </el-select>

                        <el-select
                                v-model="ruletmp"
                                collapse-tags
                                style="margin-left: 20px;"
                                placeholder="请选择">
                            <el-option
                                    v-for="item in rule"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                        <el-button type="primary" plain  @click="addParamRule()">添加</el-button>
                        <el-button plain @click="cleanParamRule()">清空</el-button>
                        <el-input
                                type="textarea"
                                :rows="2"
                                placeholder="请输入内容"
                                v-model="accForm.simple.paramFilter">
                        </el-input>
                    </el-form-item>
                </el-form>
                </el-card>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="accFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="doSave('accFormRef')">确 定</el-button>
                </div>
            </Modal>
            <!-- </el-dialog> -->

            <!--定制策略界面-->
            <Modal v-model="customACCTableVisible" title="定制策略配置" width='50%'>
                <el-card>
                <el-table :data="cusAccDate.data.list">
                    <el-table-column property="requesterSerialNo" label="请求方标识" width="150"></el-table-column>
                    <el-table-column property="requesterName" label="请求方名称" width="200"></el-table-column>
                    <el-table-column label="操作" width="450">
                        <template slot-scope="scope">
                            <el-button size="small" @click="editCusAccFrom(scope.$index, scope.row)">定制</el-button>

                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" @current-change="cusHandleCurrentPageChange"
                            :current-page="cusAccDate.data.pageNum"
                            :page-size="cusAccDate.data.pageSize" :total="cusAccDate.data.total">
                </el-pagination>
                </el-card>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="customACCTableVisible = false">取 消</el-button>
                </div>
            </Modal>

            <Modal v-model="acc_customFormVisible" title="定制策略配置" width='50%'>
                <el-card>
                <el-form :model="cusAccFrom" ref="cusAFormRef" :rules="formRules">
                    <el-form-item label="频率" :label-width="formLabelWidth" prop="frequency">
                        <el-input placeholder="请输入内容" v-model="cusAccFrom.simple.frequency" class="input-with-select">
                            <el-select v-model="cusAccFrom.select" slot="append" placeholder="请选择">
                                <el-option label="次/小时" value="H"></el-option>
                                <el-option label="次/每日" value="D"></el-option>
                                <el-option label="次/每周" value="W"></el-option>
                                <el-option label="次/每月" value="M"></el-option>
                            </el-select>

                        </el-input>
                    </el-form-item>
                    <el-form-item label="时间段" :label-width="formLabelWidth" prop="">
                    <!-- <el-input placeholder="请输入cron表达式" v-model="cusAccFrom.simple.timeSlot" auto-complete="off"></el-input>-->
                        <el-time-select placeholder="起始时间" v-model="cusAccFrom.startTime" :picker-options="{
                            start: '00:00', step: '00:15', end: '23:59' }">
                        </el-time-select>
                        <el-time-select placeholder="结束时间" v-model="cusAccFrom.endTime" :picker-options="{
                        start: '00:00', step: '00:15', end: '23:59', minTime: cusAccFrom.startTime }">
                        </el-time-select>
                    </el-form-item>
                </el-form>
                </el-card>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="acc_customFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="doSaveCus('cusAFormRef')">确 定</el-button>
                </div>
            </Modal>
        </el-row>
    </div>
</template>
<script>
    import canEditTable from './components/canEditTable.vue';
    import {
        dict_getRootListByType,
        dict_getSubNodeListByPid,
        ser_add,
        ser_changeOnLineStatus,
        ser_check,
        ser_del,
        acc_searchByCondition,
        acc_getAccessCtrlInfo,
        acc_add,
        ser_update,
        cusAcc_searchByCondition,
        cusAcc_getInfo,
        cus_acc_add

    } from '../api/api.js';
    import utils from '../api/utils.js';
    import Card from "iview/src/components/card/card";

    export default {
        components: {
            Card,
            canEditTable
        },
        data() {
            return {
                resultDate: {data:{total:0, pageNum: 0}},
                cusAccDate: {pageNum: {},
                data:{
                    list:[],
                    pageNum:1,
                    pageSize:5,
                    total:0
                }},
                dialogFormVisible: false,
                formLabelWidth: '120px',// 新增界面label大小
                addForm: {
                    apiType:'',
                    paramInfos: [],
                    responseInfos:[],
                },
                acc_customFormVisible:false,
                cusAccFrom:{
                    simple:{
                        serviceId:'',
                        requestId:'',
                        timeSlot:'',
                        frequency:''
                    },
                    select:'H',
                    startTime:'00:00',
                    endTime:'23:59'

                },
                accForm:{
                    simple:{
                        serviceId:'',
                        ipBlack:'',
                        ipWhite:'',
                        timeSlot:'',
                        frequency:'',
                        datasize:'',
                        keyword:'',
                        paramFilter:'',
                        switchButton:''
                    },
                    keySel:[],
                    keyword:[],
                    paramInfo:[],
                    paramRule:[],
                    temp:{},
                    tmp:{},
                    select:'H',
                    startTime:'00:00',
                    endTime:'23:59'


                },
                rule:[],
                paramtmp:'',
                ruletmp:'',
                textarea:'',
                customACCTableVisible:false,
                //
                select:[],
                //
                updateForm: {
                    paramInfos: [],
                    responseInfos:[],
                },// ---------  更新
                updateFormVisible: false,
                accFormVisible:false,
                //表单校验规则
                formRules: { // 新增界面校验规则
                    frequency: [
                        {  message: '请输入接口标识', trigger: 'blur',}
                    ]

                },
                // 查询条件
                conditionForm: {searchType: "", keyword: "", pageSize: 5 , policeType:"" },
                cusAccConditionForm: {pageSize: 5 },
                searchTypeOptions: [{
                    value: 'name',
                    label: '接口名称'
                }, {
                    value: 'serialNo',
                    label: '接口标识'
                }, {
                    value: 'organization',
                    label: '管理单位名称'
                }, {
                    value: 'all',
                    label: '全部',
                }],


                treeDefaultProps: {
                    label: 'name'
                },
                // 是否非第一次加载页面
                isNoFirstLoad:false,

                test: {
                    test: [
                        { required: true, message: '请输入值', trigger: 'blur' }
                    ]
                },
            };
        },
        methods: {
            checkIp:function(name,id,form){
                if(form[name] !=''){
                    if(form[name].indexOf("/")>0){
                        var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g //匹配IP地址的正则表达式
                        if (re.test(form[name])) {
                            if (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256)
                                console.info("true--->");
                        }else{
                            this.$message({
                                message: '请输入正确的ip地址',
                                type: 'info'
                            });
                            document.getElementById(id).value = "";
                            form[name] = '';
                            document.getElementById(id).focus();
                            console.info("false====");
                        }
                    }else{
                        this.$message({
                            message: '请输入正确的ip地址',
                            type: 'info'
                        });
                        document.getElementById(id).value = "";
                        form[name] = '';
                        document.getElementById(id).focus();
                    }

                }
            },
            checkNum:function (name,id,form) {
                let _this = this;
                let reg = /^[1-9]\d*$/;
                if (form[name]) {
                    if (new RegExp(reg).test(form[name]) ==false) {
                        this.$message({
                            message: '请输入数字',
                            type: 'info'
                        });
                        document.getElementById(id).value = "";
                        form[name] = '';
                        document.getElementById(id).focus();
                    }
                }

            },
            loadNode(node, resolve) {
                let _this = this
                if (node.level === 0) {// 第一次加载页面，树没数据就是==0
                    // dict_getRootListByType({"type":"jobCategory","isPageAble":false})
                    //     .then(res => {
                    //         resolve(res.data.data);
                    //     }).catch(function (error) {
                    //     _this.$message.warning('系统异常 ');
                    // });
                    resolve(utils.getDictDatasByType("jobCategory"))
                    return;
                }
                if(node.data.id>0){
                    // dict_getSubNodeListByPid({"pid":node.data.id,"isPageAble":false})
                    //     .then(res => {
                    //         resolve(res.data.data);
                    //     }).catch(function (error) {
                    //     _this.$message.warning('系统异常 ');
                    // });
                    resolve(utils.getDictDatasByPid(node.data.id))
                    return;
                }
            },
            handleCurrentPageChange: function (currentPage) {// 翻页动作
                this.currentPage = currentPage;
                this.onSearch();// 翻页后刷新页面数据
            },
            cusHandleCurrentPageChange: function (currentPage) {// 翻页动作
                this.accCurrentPage = currentPage;
                this.searchCusAcc( this.cusAccDate.temParam);// 翻页后刷新页面数据
            },
            handleClose(done) { // 新增界面关闭事件
                this.$confirm('确认关闭？', "提示").then(_ => {
                    done();
                }).catch(_ => {
                });
            },
            submitForm(formName) { // 新增界面提交事件
                let params = Object.assign({}, this.$refs[formName]._props.model);
                params.paramInfos = params.paramInfos.filter(function(item){
                    if(item.name){
                        return item;
                    }

                })

                params.responseInfos = params.responseInfos.filter(function(item){
                    if(item.name){
                        return item;
                    }

                })
                console.log(params);

                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            ser_add(params).then(res => {
                                console.log(res.data.msg);
                                this.$message.success(res.data.msg);
                                if (res.data.code == 'S100101') {
                                    this.addForm = {};
                                    this.onSearch();
                                }
                            }).catch(err => {
                                this.$message.error("系统异常");
                                console.log(err);
                            });
                            this.dialogFormVisible = false;
                        });
                    }
                });
            },
            searchCusAcc(param){

                let _this = this;
              //  console.info(param.serialNo);
                _this.cusAccDate.serviceSerialNo = param.serialNo;
                _this.cusAccDate.temParam = param;
                _this.cusAccDate.pageNum = _this.accCurrentPage;
                _this.cusAccConditionForm.searchType ='serviceSerialNo';
                _this.cusAccConditionForm.keyword = param.serialNo+'';
                cusAcc_searchByCondition(_this.cusAccConditionForm)
                    .then(res => {
                        _this.cusAccDate = res.data;
                        _this.cusAccDate.temParam = param;
                        console.info(_this.cusAccDate);console.info("cusAcc");
                    }).catch(function (error) {
                    console.log(error);
                    this.$message.warning('系统异常 ');
                });
                _this.customACCTableVisible = true;
            },
            // 查询
            onSearch(){
                var _this = this;


                // if(this.isNoFirstLoad){// todo 这里把树里边的查询条件取出来 赋值到 policeType 传到后台
                    // console.log(this.$refs.tree.getCheckedNodes());
                    // console.log(this.$refs.tree.getCheckedKeys());
                    // _this.conditionForm.policeType=this.$refs.tree.getCheckedKeys();
                // }
                // this.isNoFirstLoad=true;


                _this.conditionForm.pageNum = _this.currentPage;
                acc_searchByCondition(_this.conditionForm)
                    .then(res => {
                        _this.resultDate = res.data;
                        console.info(_this.resultDate);console.info("serach");
                    }).catch(function (error) {
                    console.log(error);
                    this.$message.warning('系统异常 ');
                });
            },
            resetChecked() { // 清空所有选择的节点
                this.$refs.tree.setCheckedKeys([]);
            },
            //删除
            handleDel (index, row) { // 数据项删除操作
                this.$confirm('是否删除当前该记录?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    ser_del(row.id).then((res) => {
                        if (res.data.code == 'S100101') {
                            this.$message.success('删除成功!');
                            this.onSearch();
                        } else {
                            this.$message.warning('删除失败! ' + res.data.msg);
                            this.onSearch();
                        }
                    }).catch((res) => {
                        this.$message.error('删除失败!');
                    });
                })
            },
            showUpdateForm(index, row){
                this.updateForm = {};
                this.updateFormVisible = true;
                this.updateForm = Object.assign({}, row);//todo 需要删除子对象
                this.updateForm.paramInfos.push({});// 临时解决 添加参数项的操作按钮消失问题 todo
                this.updateForm.paramInfos.pop();
                this.updateForm.responseInfos.push({});// 临时解决 添加参数项的操作按钮消失问题 todo
                this.updateForm.responseInfos.pop();
            },
            showCusAccForm(index, row){
                var cusparam = {};
                cusparam.serviceId = row.id;
                cusparam.serialNo = row.serialNo;
                this.searchCusAcc(cusparam);

            },
            editCusAccFrom(index, row){
                var _this = this;
                var param = {};
                param.serviceId = _this.cusAccDate.temParam.serviceId;
                param.requesterId = row.requesterId;
               // console.info(param);
                var result = {};
                cusAcc_getInfo(param).then(res => {
                     result = res.data.data;
                    //console.info(result);console.info("accParam====");
                    if(result!=null){
                        let freqStr = result.frequency;
                        if(freqStr!='' && freqStr!=null){
                            let dw = freqStr.substr(0,1);
                            _this.cusAccFrom.select = dw;
                            result.frequency = freqStr.substr(1);
                        }
                        //拆分cron表达式
                        if(result.timeSlot!='' && result.timeSlot!=null){
                            let arr = result.timeSlot.split(" ");
                            let minute = arr[1].split("-");
                            let hour = arr[2].split("-");
                            let start = hour[0]+":"+minute[0];
                            let end = hour[1]+":"+minute[1];
                           // console.info(start+"===="+end);
                            _this.cusAccFrom.startTime = start;
                            _this.cusAccFrom.endTime = end;
                        }

                    }
                    _this.cusAccFrom.simple = Object.assign({}, result);
                    _this.acc_customFormVisible =true;

                }).catch(function (error) {
                    console.log(error);
                    _this.$message.warning('系统异常 ');
                });
            },
            showAccFrom(index, row){
                var _this = this;
                var param = {};
                param.serviceId = row.id;
                var result = {};
                acc_getAccessCtrlInfo(param)
                    .then(res => {
                        result = res.data.data;
                         console.info(result);console.info("result");
                         if(result.acInfo!=null){
                            // console.info("null")

                             let freqStr = result.acInfo.frequency;
                             if(freqStr!='' && freqStr!=null){
                                 let dw = freqStr.substr(0,1);
                                 _this.accForm.select = dw;
                                 result.acInfo.frequency = freqStr.substr(1);
                             }
                         }

                        _this.accForm.simple = Object.assign({}, result.acInfo);
                        _this.paramtmp = '';
                        _this.ruletmp = '';
                        _this.accForm.keySel = [];
                        if(result.acInfo!=null){
                            if(result.acInfo.keyword!='' && result.acInfo.keyword!=null ){
                                _this.accForm.keySel.push(parseInt(result.acInfo.keyword));
                            }
                            //拆分cron表达式
                            if(result.acInfo.timeSlot!='' && result.acInfo.timeSlot!=null){
                                let arr = result.acInfo.timeSlot.split(" ");
                                let minute = arr[1].split("-");
                                let hour = arr[2].split("-");
                                let start = hour[0]+":"+minute[0];
                                let end = hour[1]+":"+minute[1];
                               // console.info(start+"===="+end);
                                _this.accForm.startTime = start;
                                _this.accForm.endTime = end;
                            }
                        }
                        _this.accForm.keyword = result.keyword;
                        _this.accForm.paramInfo = result.paramInfo;

                        _this.rule = result.paramRule;
                       // console.info(_this.accForm);console.info("result");
                        _this.accForm.simple.serviceId = param.serviceId;
                        _this.accFormVisible = true;
                    }).catch(function (error) {
                    console.log(error);
                    _this.$message.warning('系统异常 ');
                });

            },
            showAddForm(){
                this.dialogFormVisible = true;
                this.addForm.paramInfos.push({});// 临时解决 添加参数项的操作按钮消失问题 todo
                this.addForm.paramInfos.pop();
                this.addForm.responseInfos.push({});// 临时解决 添加参数项的操作按钮消失问题 todo
                this.addForm.responseInfos.pop();
            },
            doSaveCus(formName){
                var _this = this;
                let params = Object.assign({}, this.$refs[formName]._props.model);
                //拼接后台数据，keyword 和频率的字符串
               // console.info(params);console.info("cusparams");
               /* return;*/
                let startTimeArr = params.startTime.split(":");
                let endTimeArr = params.endTime.split(":");
                //0 0 10-11 * * ?
                let timeruleStr = "0 "+startTimeArr[1]+"-"+endTimeArr[1]+" "+startTimeArr[0]+"-"+endTimeArr[0]+" * * ?"

              //  console.info(params);console.info("cusparams");
                let freqStr = '';
                if(params.simple.frequency == ''){
                    freqStr ='';
                }else{

                    freqStr = params.select+ params.simple.frequency+'';
                }
                params.frequency = freqStr;
                params.simple.timeSlot = timeruleStr;
                this.$confirm('确认提交吗？', '提示', {}).then(() => {
                    cus_acc_add(params).then((res) => {
                        // debugger
                        if (res.data.code == 'S100101') {
                            _this.$message.success('添加成功!');
                            _this.onSearch();
                        } else {
                            _this.$message.warning('添加失败! ' + res.data.msg);
                            _this.onSearch();
                        }
                        _this.acc_customFormVisible = false;
                    }).catch((res) => {
                        _this.$message.error('添加失败!');
                    });
                    this.acc_customFormVisible = false;
                });
            },
            doSave(formName){
                var _this = this;
                let params = Object.assign({}, this.$refs[formName]._props.model);
                let startTimeArr = params.startTime.split(":");
                let endTimeArr = params.endTime.split(":");
                //0 0 10-11 * * ?
                let timeruleStr = "0 "+startTimeArr[1]+"-"+endTimeArr[1]+" "+startTimeArr[0]+"-"+endTimeArr[0]+" * * ?"

                //拼接后台数据，keyword 和频率的字符串
              //  console.info(timeruleStr);
              //  console.info(params);console.info("=========new怕让美食")

               /// return;
                let keywordStr = '';
                let keys = params.keySel;
                if(keys.length!=0){

                    for(let i=0,len=keys.length;i<len;i++){
                        keywordStr+=keys[i]+',';
                    }
                    keywordStr = keywordStr.substr(0,keywordStr.length-1);
                }
                let freqStr = '';
                if(params.simple.frequency == ''){
                    freqStr ='';
                }else{

                    freqStr = params.select+ params.simple.frequency+'';
                }
                params.simple.frequency = freqStr;
                params.simple.keyword = keywordStr;
                params.simple.timeSlot = timeruleStr;
                this.$confirm('确认提交吗？', '提示', {}).then(() => {
                    acc_add(params.simple).then((res) => {
                        // debugger
                        if (res.data.code == 'S100101') {
                            _this.$message.success('添加成功!');
                            _this.onSearch();
                        } else {
                            _this.$message.warning('添加失败!' + res.data.msg);
                            _this.onSearch();
                        }
                    }).catch((res) => {
                        // debugger
                        _this.$message.error('添加失败!');
                    });
                    this.accFormVisible = false;
                });
            },
            doUpdate(formName){
                let params = Object.assign({}, this.$refs[formName]._props.model);
                params.paramInfos = params.paramInfos.filter(function(item){
                    if(item.name){
                        return item;
                    }

                })

                params.responseInfos = params.responseInfos.filter(function(item){
                    if(item.name){
                        return item;
                    }

                })

                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            ser_update(params).then((res) => {
                                if (res.data.code == 'S100101') {
                                    this.$message.success('更新成功!');
                                    this.onSearch();
                                } else {
                                    this.$message.warning('更新失败! ' + res.data.msg);
                                    this.onSearch();
                                }
                            }).catch((res) => {
                                this.$message.error('更新失败!');
                            });
                            this.updateFormVisible = false;
                        });
                    }
                });
            },
            changeOnLineStatus(row){// 上下线
                ser_changeOnLineStatus({id:row.id}).then((res)=>{
                    if (res.data.code == 'S100101') {
                        this.$message.success(res.data.msg);
                        this.onSearch();
                    } else {
                        this.$message.warning('操作失败! ' + res.data.msg);
                        this.onSearch();
                    }
                }).catch((err)=>{
                    this.$message.error('操作失败!');
                    console.log('操作失败：'+err);
                });
            },
            audit(row,yesOrNo){// 审核
                let status ;
                if(yesOrNo=='yes'){
                    status=3;
                }else if(yesOrNo=='no'){
                    status=4
                }else{this.$message.error("异常操作!!!");return false;}
                ser_check({id:row.id,status:status}).then((res)=>{
                    if (res.data.code == 'S100101') {
                        this.$message.success(res.data.msg);
                        this.onSearch();
                    } else {
                        this.$message.warning('操作失败! ' + res.data.msg);
                        this.onSearch();
                    }
                }).catch((err)=>{
                    this.$message.error('审核失败!');
                    console.log('审核失败：'+err);
                });
            },
            formatCommDatas(row, column){
                return utils.formatCommDatas(row, column);
            },
            formatDicTionary(value,type){
                return utils.formatDicTionary(value,type);
            },
            cleanParamRule(){
              let _this = this;
              _this.accForm.simple.paramFilter = '';
            },
            addParamRule(){//添加配对参数规则到textarea
                let _this = this;
                let text = _this.accForm.simple.paramFilter;
               // console.info(text);
                let obj = {};
                obj.name = _this.paramtmp;
                obj.value = _this.ruletmp;

                if(obj.name == ''&& obj.value ==''){
                  //  console.info("参数为空！");
                    return;

                }

                let result = [];
                if(text!=''){
                    result = JSON.parse(text);

                }
                result.push(obj);
                let str = JSON.stringify(result)
                _this.accForm.simple.paramFilter = str;


            },
            addParamInfoElement4AddForm(){// 新增表单-新增参数子对象
                this.addForm.paramInfos.push({});
                console.log(this.addForm)
                this.showAddForm();
                // todo  添加一行的时候应该进入编辑状态
//                editButton(this,this.render,this.addForm.paramInfos[this.addForm.paramInfos.length-1],this.addForm.paramInfos.length-1);//(vm, h, currentRow, index)  addFormParamInfosTab
            },
            addResponseInfoElement4AddForm(){// 新增表单-新增响应参数子对象
                this.addForm.responseInfos.push({});
                console.log(this.addForm)
                this.showAddForm();
            },
            addParamInfoElement4UpdateForm(){// 编辑表单-新增参数子对象
                this.updateForm.paramInfos.push({});
                console.log(this.updateForm)
            },
            addResponseInfoElement4UpdateForm(){// 编辑表单-新增响应参数子对象
                this.updateForm.responseInfos.push({});
                console.log(this.updateForm)
            },
            changeAddFormApiType(val){// 新增表单选择接口类型
                console.log(this.addForm.apiType);
                if(this.addForm.apiType==1){// http+json 清空另一种类型参数
                    this.addForm.invokMethod=null;
                    // 修改必填项
                    this.formRules.httpMethod[0].required=true;
                    this.formRules.invokMethod[0].required=false;
                }else if(this.addForm.apiType==2){// soap  清空另一种类型参数
                    this.addForm.httpMethod=null;
                    // 修改必填项
                    this.formRules.invokMethod[0].required=true;
                    this.formRules.httpMethod[0].required=false;
                }else{
                    this.$message.error("浏览器异常，请刷新页面")
                }
            },
            changeUpdateFormApiType(val){// 编辑表单选择接口类型
                console.log(this.updateForm.apiType);
                if(this.updateForm.apiType==1){// http+json 清空另一种类型参数
                    this.updateForm.invokMethod=null;
                    // 修改必填项
                    this.formRules.httpMethod[0].required=true;
                    this.formRules.invokMethod[0].required=false;
                }else if(this.updateForm.apiType==2){// soap  清空另一种类型参数
                    this.updateForm.httpMethod=null;
                    // 修改必填项
                    this.formRules.invokMethod[0].required=true;
                    this.formRules.httpMethod[0].required=false;
                }else{
                    this.$message.error("浏览器异常，请刷新页面")
                }
            },
        },
        computed: {
            // method1: function(){
            //     return  getCheckedNodes()
            // }
        },
        created() {

        },
        watch:{
            addForm(a,b){// 解决‘添加子对象’操作按钮不显示bug，重新刷新对象
                this.showAddForm();
            },
        },
        mounted(){
            this.onSearch();

        },



    };
</script>


